tonal-distance ![npm version](https://img.shields.io/npm/v/tonal-distance.svg)
![tonal](https://img.shields.io/badge/tonal-distance-yellow.svg)
tonal-distance
is a collection of functions to find distances between music notes.
This is part of tonal music theory library.
You can install via npm: npm i --save tonal-distance
API Reference
- distance(from, to) ⇒
Interval
Find distance between two pitches. Both pitches MUST be of the same type.
Distances between pitch classes always returns ascending intervals.
Distances between intervals substract one from the other.
- distInSemitones(from, to) ⇒
Integer
Get the distance between two notes in semitones
- interval()
An alias for distance
distance(from, to) ⇒ Interval
Find distance between two pitches. Both pitches MUST be of the same type.
Distances between pitch classes always returns ascending intervals.
Distances between intervals substract one from the other.
Kind: global function
Returns: Interval
- the distance between pitches
Param | Type | Description |
---|
from | Pitch | String | distance from |
to | Pitch | String | distance to |
Example
import { distance } from 'tonal-distance'
distance('C2', 'C3')
distance('G', 'B')
var tonal = require('tonal')
tonal.distance('M2', 'P5')
distInSemitones(from, to) ⇒ Integer
Get the distance between two notes in semitones
Kind: global function
Returns: Integer
- the distance in semitones or null if not valid notes
Param | Type | Description |
---|
from | String | Pitch | first note |
to | String | Pitch | last note |
Example
import { distInSemitones } from 'tonal-distance'
distInSemitones('C3', 'A2')
tonal.distInSemitones('C3', 'G3')
interval()
An alias for distance
Kind: global function